const Koa = require('koa')
const app = new Koa()

const { query } = require('./mysql/async-db')

async function selectAllData() {
  const sql = 'SELECT * FROM tdb_goods'
  const result =  await query(sql)
  return result
}

app.use(async ctx => {
  const result = await selectAllData()
  ctx.body = {
    success: true,
    data: result,
  }
})

app.listen(4000, () => {
  console.log('[demo] request post is starting at port 4000')
})